<template>
  <div>
    <h2>所在学校名称：{{schoolName}}</h2>
    <h1>学校分校数量：{{schools.length}}</h1>

    <h2>学生列表</h2>
    <ul v-for="stu in students" :key="stu.id">
      <li>{{ stu.name }}</li>
    </ul>
    <input type="text" placeholder="输入学生名称" v-model="name">
    <button @click="ADDSTU(name)">添加一个学生</button>
    <button @click="addWang(name)">添加一个学生,只允许姓王</button>
  </div>
</template>

<script>
import {mapState,mapActions,mapMutations} from 'vuex'
export default {
  name: "Student",
  data(){
    return{
      name:''
    }
  },

  computed:{
    ...mapState('schoolAbout',['schoolName','schools']),
    ...mapState('studentAbout',['students'])
  },
  methods:{
    ...mapMutations('studentAbout',['ADDSTU']),
    ...mapActions('studentAbout',['addWang']),

  }
}
</script>

<style scoped>

</style>
